package com.qing.springbootorderservice.service;

import com.qing.springbootorderservice.dao.OrderDataBaseService;
import com.qing.springbootorderservice.mq.OrderMQService;
import com.qing.springbootorderservice.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MQOrderService {

	@Autowired
	private OrderDataBaseService orderDataBaseService;

	@Autowired
	private OrderMQService orderMQService;


	//创建订单,采用分布式事务
	public void createOrder(Order orderInfo) throws Exception {
		//1. 订单信息 ---插入订单系统，订单数据库事务
		orderDataBaseService.saveOrder(orderInfo);
		//2. 通过http接口发送订单信息到运单系统
		orderMQService.sendMessage(orderInfo);
	}
}
